<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span id="local-6989586621679533976"><span id="local-6989586621679533977"></span></span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP
           , NoImplicitPrelude
           , ExistentialQuantification
  #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# OPTIONS_GHC -funbox-strict-fields #-}</span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Module      :  GHC.IO.Handle.Types</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 1994-2009</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- Basic types for the implementation of IO Handles.</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.Handle.Types</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-24"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier">Handle</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier">Handle__</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#showHandle"><span class="hs-identifier">showHandle</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#checkHandleInvariants"><span class="hs-identifier">checkHandleInvariants</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferList"><span class="hs-identifier">BufferList</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier">HandleType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#isReadableHandleType"><span class="hs-identifier">isReadableHandleType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#isWritableHandleType"><span class="hs-identifier">isWritableHandleType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#isReadWriteHandleType"><span class="hs-identifier">isReadWriteHandleType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#isAppendHandleType"><span class="hs-identifier">isAppendHandleType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier">BufferMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>      </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#BufferCodec"><span class="hs-identifier">BufferCodec</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier">NewlineMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier">Newline</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#nativeNewline"><span class="hs-identifier">nativeNewline</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>      </span><span class="annot"><a href="GHC.IO.Handle.Types.html#universalNewlineMode"><span class="hs-identifier">universalNewlineMode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#noNewlineTranslation"><span class="hs-identifier">noNewlineTranslation</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#nativeNewlineMode"><span class="hs-identifier">nativeNewlineMode</span></a></span><span>
</span><span id="line-34"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#undef DEBUG
</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.MVar.html"><span class="hs-identifier">GHC.MVar</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html"><span class="hs-identifier">GHC.IO.Buffer</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.BufferedIO.html"><span class="hs-identifier">GHC.IO.BufferedIO</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html"><span class="hs-identifier">GHC.IO.Encoding.Types</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IORef.html"><span class="hs-identifier">GHC.IORef</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Show.html"><span class="hs-identifier">GHC.Show</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Read.html"><span class="hs-identifier">GHC.Read</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Word.html"><span class="hs-identifier">GHC.Word</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Device.html"><span class="hs-identifier">GHC.IO.Device</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Typeable.html"><span class="hs-identifier">Data.Typeable</span></a></span><span class="hs-cpp">
#if defined(DEBUG)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Monad</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- Handle type</span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span class="hs-comment">--  A Handle is represented by (a reference to) a record</span><span>
</span><span id="line-58"></span><span class="hs-comment">--  containing the state of the I/O port/device. We record</span><span>
</span><span id="line-59"></span><span class="hs-comment">--  the following pieces of info:</span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="hs-comment">--    * type (read,write,closed etc.)</span><span>
</span><span id="line-62"></span><span class="hs-comment">--    * the underlying file descriptor</span><span>
</span><span id="line-63"></span><span class="hs-comment">--    * buffering mode</span><span>
</span><span id="line-64"></span><span class="hs-comment">--    * buffer, and spare buffers</span><span>
</span><span id="line-65"></span><span class="hs-comment">--    * user-friendly name (usually the</span><span>
</span><span id="line-66"></span><span class="hs-comment">--      FilePath used when IO.openFile was called)</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="hs-comment">-- Note: when a Handle is garbage collected, we want to flush its buffer</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- and close the OS file handle, so as to free up a (precious) resource.</span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span class="hs-comment">-- | Haskell defines operations to read and write characters from and to files,</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- represented by values of type @Handle@.  Each value of this type is a</span><span>
</span><span id="line-73"></span><span class="hs-comment">-- /handle/: a record used by the Haskell run-time system to /manage/ I\/O</span><span>
</span><span id="line-74"></span><span class="hs-comment">-- with file system objects.  A handle has at least the following properties:</span><span>
</span><span id="line-75"></span><span class="hs-comment">--</span><span>
</span><span id="line-76"></span><span class="hs-comment">--  * whether it manages input or output or both;</span><span>
</span><span id="line-77"></span><span class="hs-comment">--</span><span>
</span><span id="line-78"></span><span class="hs-comment">--  * whether it is /open/, /closed/ or /semi-closed/;</span><span>
</span><span id="line-79"></span><span class="hs-comment">--</span><span>
</span><span id="line-80"></span><span class="hs-comment">--  * whether the object is seekable;</span><span>
</span><span id="line-81"></span><span class="hs-comment">--</span><span>
</span><span id="line-82"></span><span class="hs-comment">--  * whether buffering is disabled, or enabled on a line or block basis;</span><span>
</span><span id="line-83"></span><span class="hs-comment">--</span><span>
</span><span id="line-84"></span><span class="hs-comment">--  * a buffer (whose length may be zero).</span><span>
</span><span id="line-85"></span><span class="hs-comment">--</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- Most handles will also have a current I\/O position indicating where the next</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- input or output operation will occur.  A handle is /readable/ if it</span><span>
</span><span id="line-88"></span><span class="hs-comment">-- manages only input or both input and output; likewise, it is /writable/ if</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- it manages only output or both input and output.  A handle is /open/ when</span><span>
</span><span id="line-90"></span><span class="hs-comment">-- first allocated.</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- Once it is closed it can no longer be used for either input or output,</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- though an implementation cannot re-use its storage while references</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- remain to it.  Handles are in the 'Show' and 'Eq' classes.  The string</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- produced by showing a handle is system dependent; it should include</span><span>
</span><span id="line-95"></span><span class="hs-comment">-- enough information to identify the handle for debugging.  A handle is</span><span>
</span><span id="line-96"></span><span class="hs-comment">-- equal according to '==' only to itself; no attempt</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- is made to compare the internal state of different handles for equality.</span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-keyword">data</span><span> </span><span id="Handle"><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-var">Handle</span></a></span></span><span>
</span><span id="line-100"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="FileHandle"><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-var">FileHandle</span></a></span></span><span>                          </span><span class="hs-comment">-- A normal handle to a file</span><span>
</span><span id="line-101"></span><span>        </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                        </span><span class="hs-comment">-- the file (used for error messages</span><span>
</span><span id="line-102"></span><span>                                        </span><span class="hs-comment">-- only)</span><span>
</span><span id="line-103"></span><span>        </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="DuplexHandle"><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-var">DuplexHandle</span></a></span></span><span>                        </span><span class="hs-comment">-- A handle to a read/write stream</span><span>
</span><span id="line-106"></span><span>        </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>                        </span><span class="hs-comment">-- file for a FIFO, otherwise some</span><span>
</span><span id="line-107"></span><span>                                        </span><span class="hs-comment">--   descriptive string (used for error</span><span>
</span><span id="line-108"></span><span>                                        </span><span class="hs-comment">--   messages only)</span><span>
</span><span id="line-109"></span><span>        </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">)</span><span>                </span><span class="hs-comment">-- The read side</span><span>
</span><span id="line-110"></span><span>        </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">)</span><span>                </span><span class="hs-comment">-- The write side</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-comment">-- NOTES:</span><span>
</span><span id="line-113"></span><span class="hs-comment">--    * A 'FileHandle' is seekable.  A 'DuplexHandle' may or may not be</span><span>
</span><span id="line-114"></span><span class="hs-comment">--      seekable.</span><span>
</span><span id="line-115"></span><span>
</span><span id="line-116"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-117"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679533958"><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-type">Eq</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-118"></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679533953"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679533953"><span class="hs-identifier hs-var">h1</span></a></span></span><span class="hs-special">)</span><span>     </span><span id="local-6989586621679533952"><span class="annot"><span class="annottext">== :: Handle -&gt; Handle -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">==</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679533951"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679533951"><span class="hs-identifier hs-var">h2</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679533953"><span class="hs-identifier hs-var">h1</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__ -&gt; MVar Handle__ -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679533951"><span class="hs-identifier hs-var">h2</span></a></span><span>
</span><span id="line-119"></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679533950"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679533950"><span class="hs-identifier hs-var">h1</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679533949"><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679533949"><span class="hs-identifier hs-var">h2</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679533950"><span class="hs-identifier hs-var">h1</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__ -&gt; MVar Handle__ -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><a href="#local-6989586621679533949"><span class="hs-identifier hs-var">h2</span></a></span><span>
</span><span id="line-120"></span><span> </span><span class="annot"><span class="annottext">Handle
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-keyword">data</span><span> </span><span id="Handle__"><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-var">Handle__</span></a></span></span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679533948"><span class="annot"><a href="#local-6989586621679533948"><span class="hs-identifier hs-type">dev</span></a></span></span><span> </span><span id="local-6989586621679533947"><span class="annot"><a href="#local-6989586621679533947"><span class="hs-identifier hs-type">enc_state</span></a></span></span><span> </span><span id="local-6989586621679533946"><span class="annot"><a href="#local-6989586621679533946"><span class="hs-identifier hs-type">dec_state</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Device.html#RawIO"><span class="hs-identifier hs-type">RawIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679533948"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Device.html#IODevice"><span class="hs-identifier hs-type">IODevice</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679533948"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.BufferedIO.html#BufferedIO"><span class="hs-identifier hs-type">BufferedIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679533948"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679533948"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span>
</span><span id="line-124"></span><span>    </span><span id="Handle__"><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-var">Handle__</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-125"></span><span>      </span><span id="haDevice"><span class="annot"><span class="annottext">()
</span><a href="GHC.IO.Handle.Types.html#haDevice"><span class="hs-identifier hs-var hs-var">haDevice</span></a></span></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="#local-6989586621679533948"><span class="hs-identifier hs-type">dev</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-126"></span><span>      </span><span id="haType"><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier hs-type">HandleType</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- type (read/write/append etc.)</span><span>
</span><span id="line-127"></span><span>      </span><span id="haByteBuffer"><span class="annot"><span class="annottext">Handle__ -&gt; IORef (Buffer Word8)
</span><a href="GHC.IO.Handle.Types.html#haByteBuffer"><span class="hs-identifier hs-var hs-var">haByteBuffer</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- See [note Buffering Implementation]</span><span>
</span><span id="line-128"></span><span>      </span><span id="haBufferMode"><span class="annot"><span class="annottext">Handle__ -&gt; BufferMode
</span><a href="GHC.IO.Handle.Types.html#haBufferMode"><span class="hs-identifier hs-var hs-var">haBufferMode</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier hs-type">BufferMode</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-129"></span><span>      </span><span id="haLastDecode"><span class="annot"><span class="annottext">()
</span><a href="GHC.IO.Handle.Types.html#haLastDecode"><span class="hs-identifier hs-var hs-var">haLastDecode</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679533946"><span class="hs-identifier hs-type">dec_state</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-130"></span><span>      </span><span class="hs-comment">-- ^ The byte buffer just  before we did our last batch of decoding.</span><span>
</span><span id="line-131"></span><span>      </span><span id="haCharBuffer"><span class="annot"><span class="annottext">Handle__ -&gt; IORef (Buffer CharBufElem)
</span><a href="GHC.IO.Handle.Types.html#haCharBuffer"><span class="hs-identifier hs-var hs-var">haCharBuffer</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#CharBufElem"><span class="hs-identifier hs-type">CharBufElem</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- See [note Buffering Implementation]</span><span>
</span><span id="line-132"></span><span>      </span><span id="haBuffers"><span class="annot"><span class="annottext">Handle__ -&gt; IORef (BufferList CharBufElem)
</span><a href="GHC.IO.Handle.Types.html#haBuffers"><span class="hs-identifier hs-var hs-var">haBuffers</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferList"><span class="hs-identifier hs-type">BufferList</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#CharBufElem"><span class="hs-identifier hs-type">CharBufElem</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>  </span><span class="hs-comment">-- spare buffers</span><span>
</span><span id="line-133"></span><span>      </span><span id="haEncoder"><span class="annot"><span class="annottext">()
</span><a href="GHC.IO.Handle.Types.html#haEncoder"><span class="hs-identifier hs-var hs-var">haEncoder</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoder"><span class="hs-identifier hs-type">TextEncoder</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679533947"><span class="hs-identifier hs-type">enc_state</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-134"></span><span>      </span><span id="haDecoder"><span class="annot"><span class="annottext">()
</span><a href="GHC.IO.Handle.Types.html#haDecoder"><span class="hs-identifier hs-var hs-var">haDecoder</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextDecoder"><span class="hs-identifier hs-type">TextDecoder</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679533946"><span class="hs-identifier hs-type">dec_state</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-135"></span><span>      </span><span id="haCodec"><span class="annot"><span class="annottext">Handle__ -&gt; Maybe TextEncoding
</span><a href="GHC.IO.Handle.Types.html#haCodec"><span class="hs-identifier hs-var hs-var">haCodec</span></a></span></span><span>       </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Types.html#TextEncoding"><span class="hs-identifier hs-type">TextEncoding</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-136"></span><span>      </span><span id="haInputNL"><span class="annot"><span class="annottext">Handle__ -&gt; Newline
</span><a href="GHC.IO.Handle.Types.html#haInputNL"><span class="hs-identifier hs-var hs-var">haInputNL</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier hs-type">Newline</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-137"></span><span>      </span><span id="haOutputNL"><span class="annot"><span class="annottext">Handle__ -&gt; Newline
</span><a href="GHC.IO.Handle.Types.html#haOutputNL"><span class="hs-identifier hs-var hs-var">haOutputNL</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier hs-type">Newline</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-138"></span><span>      </span><span id="haOtherSide"><span class="annot"><span class="annottext">Handle__ -&gt; Maybe (MVar Handle__)
</span><a href="GHC.IO.Handle.Types.html#haOtherSide"><span class="hs-identifier hs-var hs-var">haOtherSide</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.MVar.html#MVar"><span class="hs-identifier hs-type">MVar</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ptr to the write side of a</span><span>
</span><span id="line-139"></span><span>                                             </span><span class="hs-comment">-- duplex handle.</span><span>
</span><span id="line-140"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-141"></span><span>
</span><span id="line-142"></span><span class="hs-comment">-- we keep a few spare buffers around in a handle to avoid allocating</span><span>
</span><span id="line-143"></span><span class="hs-comment">-- a new one for each hPutStr.  These buffers are *guaranteed* to be the</span><span>
</span><span id="line-144"></span><span class="hs-comment">-- same size as the main buffer.</span><span>
</span><span id="line-145"></span><span class="hs-keyword">data</span><span> </span><span id="BufferList"><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferList"><span class="hs-identifier hs-var">BufferList</span></a></span></span><span> </span><span id="local-6989586621679533893"><span class="annot"><a href="#local-6989586621679533893"><span class="hs-identifier hs-type">e</span></a></span></span><span>
</span><span id="line-146"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="BufferListNil"><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferListNil"><span class="hs-identifier hs-var">BufferListNil</span></a></span></span><span>
</span><span id="line-147"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="BufferListCons"><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferListCons"><span class="hs-identifier hs-var">BufferListCons</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Buffer.html#RawBuffer"><span class="hs-identifier hs-type">RawBuffer</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679533893"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferList"><span class="hs-identifier hs-type">BufferList</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679533893"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>
</span><span id="line-149"></span><span class="hs-comment">--  Internally, we classify handles as being one</span><span>
</span><span id="line-150"></span><span class="hs-comment">--  of the following:</span><span>
</span><span id="line-151"></span><span>
</span><span id="line-152"></span><span class="hs-keyword">data</span><span> </span><span id="HandleType"><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier hs-var">HandleType</span></a></span></span><span>
</span><span id="line-153"></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="ClosedHandle"><span class="annot"><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span></span><span>
</span><span id="line-154"></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="SemiClosedHandle"><span class="annot"><a href="GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span></span><span>
</span><span id="line-155"></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="ReadHandle"><span class="annot"><a href="GHC.IO.Handle.Types.html#ReadHandle"><span class="hs-identifier hs-var">ReadHandle</span></a></span></span><span>
</span><span id="line-156"></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="WriteHandle"><span class="annot"><a href="GHC.IO.Handle.Types.html#WriteHandle"><span class="hs-identifier hs-var">WriteHandle</span></a></span></span><span>
</span><span id="line-157"></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="AppendHandle"><span class="annot"><a href="GHC.IO.Handle.Types.html#AppendHandle"><span class="hs-identifier hs-var">AppendHandle</span></a></span></span><span>
</span><span id="line-158"></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="ReadWriteHandle"><span class="annot"><a href="GHC.IO.Handle.Types.html#ReadWriteHandle"><span class="hs-identifier hs-var">ReadWriteHandle</span></a></span></span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isReadableHandleType"><span class="hs-identifier hs-type">isReadableHandleType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier hs-type">HandleType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-161"></span><span id="isReadableHandleType"><span class="annot"><span class="annottext">isReadableHandleType :: HandleType -&gt; Bool
</span><a href="GHC.IO.Handle.Types.html#isReadableHandleType"><span class="hs-identifier hs-var hs-var">isReadableHandleType</span></a></span></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ReadHandle"><span class="hs-identifier hs-var">ReadHandle</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-162"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isReadableHandleType"><span class="hs-identifier hs-var">isReadableHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ReadWriteHandle"><span class="hs-identifier hs-var">ReadWriteHandle</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-163"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isReadableHandleType"><span class="hs-identifier hs-var">isReadableHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isWritableHandleType"><span class="hs-identifier hs-type">isWritableHandleType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier hs-type">HandleType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-166"></span><span id="isWritableHandleType"><span class="annot"><span class="annottext">isWritableHandleType :: HandleType -&gt; Bool
</span><a href="GHC.IO.Handle.Types.html#isWritableHandleType"><span class="hs-identifier hs-var hs-var">isWritableHandleType</span></a></span></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#AppendHandle"><span class="hs-identifier hs-var">AppendHandle</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-167"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isWritableHandleType"><span class="hs-identifier hs-var">isWritableHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#WriteHandle"><span class="hs-identifier hs-var">WriteHandle</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-168"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isWritableHandleType"><span class="hs-identifier hs-var">isWritableHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ReadWriteHandle"><span class="hs-identifier hs-var">ReadWriteHandle</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-169"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isWritableHandleType"><span class="hs-identifier hs-var">isWritableHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isReadWriteHandleType"><span class="hs-identifier hs-type">isReadWriteHandleType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier hs-type">HandleType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-172"></span><span id="isReadWriteHandleType"><span class="annot"><span class="annottext">isReadWriteHandleType :: HandleType -&gt; Bool
</span><a href="GHC.IO.Handle.Types.html#isReadWriteHandleType"><span class="hs-identifier hs-var hs-var">isReadWriteHandleType</span></a></span></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#ReadWriteHandle"><span class="hs-identifier hs-type">ReadWriteHandle</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-173"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isReadWriteHandleType"><span class="hs-identifier hs-var">isReadWriteHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-174"></span><span>
</span><span id="line-175"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isAppendHandleType"><span class="hs-identifier hs-type">isAppendHandleType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier hs-type">HandleType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-176"></span><span id="isAppendHandleType"><span class="annot"><span class="annottext">isAppendHandleType :: HandleType -&gt; Bool
</span><a href="GHC.IO.Handle.Types.html#isAppendHandleType"><span class="hs-identifier hs-var hs-var">isAppendHandleType</span></a></span></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#AppendHandle"><span class="hs-identifier hs-var">AppendHandle</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-177"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#isAppendHandleType"><span class="hs-identifier hs-var">isAppendHandleType</span></a></span><span> </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span class="hs-comment">-- INVARIANTS on Handles:</span><span>
</span><span id="line-181"></span><span class="hs-comment">--</span><span>
</span><span id="line-182"></span><span class="hs-comment">--   * A handle *always* has a buffer, even if it is only 1 character long</span><span>
</span><span id="line-183"></span><span class="hs-comment">--     (an unbuffered handle needs a 1 character buffer in order to support</span><span>
</span><span id="line-184"></span><span class="hs-comment">--      hLookAhead and hIsEOF).</span><span>
</span><span id="line-185"></span><span class="hs-comment">--   * In a read Handle, the byte buffer is always empty (we decode when reading)</span><span>
</span><span id="line-186"></span><span class="hs-comment">--   * In a wriite Handle, the Char buffer is always empty (we encode when writing)</span><span>
</span><span id="line-187"></span><span class="hs-comment">--</span><span>
</span><span id="line-188"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#checkHandleInvariants"><span class="hs-identifier hs-type">checkHandleInvariants</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">
#if defined(DEBUG)
</span><span class="hs-identifier">checkHandleInvariants</span><span> </span><span class="hs-identifier">h_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-191"></span><span> </span><span class="hs-identifier">bbuf</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">readIORef</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">haByteBuffer</span><span> </span><span class="hs-identifier">h_</span><span class="hs-special">)</span><span>
</span><span id="line-192"></span><span> </span><span class="hs-identifier">checkBuffer</span><span> </span><span class="hs-identifier">bbuf</span><span>
</span><span id="line-193"></span><span> </span><span class="hs-identifier">cbuf</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">readIORef</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">haCharBuffer</span><span> </span><span class="hs-identifier">h_</span><span class="hs-special">)</span><span>
</span><span id="line-194"></span><span> </span><span class="hs-identifier">checkBuffer</span><span> </span><span class="hs-identifier">cbuf</span><span>
</span><span id="line-195"></span><span> </span><span class="hs-identifier">when</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isWriteBuffer</span><span> </span><span class="hs-identifier">cbuf</span><span> </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isEmptyBuffer</span><span> </span><span class="hs-identifier">cbuf</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-196"></span><span>   </span><span class="hs-identifier">errorWithoutStackTrace</span><span> </span><span class="hs-special">(</span><span class="hs-string">&quot;checkHandleInvariants: char write buffer non-empty: &quot;</span><span> </span><span class="hs-operator">++</span><span>
</span><span id="line-197"></span><span>          </span><span class="hs-identifier">summaryBuffer</span><span> </span><span class="hs-identifier">bbuf</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-string">&quot;, &quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">summaryBuffer</span><span> </span><span class="hs-identifier">cbuf</span><span class="hs-special">)</span><span>
</span><span id="line-198"></span><span> </span><span class="hs-identifier">when</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isWriteBuffer</span><span> </span><span class="hs-identifier">bbuf</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-identifier">isWriteBuffer</span><span> </span><span class="hs-identifier">cbuf</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-199"></span><span>   </span><span class="hs-identifier">errorWithoutStackTrace</span><span> </span><span class="hs-special">(</span><span class="hs-string">&quot;checkHandleInvariants: buffer modes differ: &quot;</span><span> </span><span class="hs-operator">++</span><span>
</span><span id="line-200"></span><span>          </span><span class="hs-identifier">summaryBuffer</span><span> </span><span class="hs-identifier">bbuf</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-string">&quot;, &quot;</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">summaryBuffer</span><span> </span><span class="hs-identifier">cbuf</span><span class="hs-special">)</span><span class="hs-cpp">

#else
</span><span id="checkHandleInvariants"><span class="annot"><span class="annottext">checkHandleInvariants :: Handle__ -&gt; IO ()
</span><a href="GHC.IO.Handle.Types.html#checkHandleInvariants"><span class="hs-identifier hs-var hs-var">checkHandleInvariants</span></a></span></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-206"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-207"></span><span class="hs-comment">-- Buffering modes</span><span>
</span><span id="line-208"></span><span>
</span><span id="line-209"></span><span class="hs-comment">-- | Three kinds of buffering are supported: line-buffering,</span><span>
</span><span id="line-210"></span><span class="hs-comment">-- block-buffering or no-buffering.  These modes have the following</span><span>
</span><span id="line-211"></span><span class="hs-comment">-- effects. For output, items are written out, or /flushed/,</span><span>
</span><span id="line-212"></span><span class="hs-comment">-- from the internal buffer according to the buffer mode:</span><span>
</span><span id="line-213"></span><span class="hs-comment">--</span><span>
</span><span id="line-214"></span><span class="hs-comment">--  * /line-buffering/: the entire output buffer is flushed</span><span>
</span><span id="line-215"></span><span class="hs-comment">--    whenever a newline is output, the buffer overflows,</span><span>
</span><span id="line-216"></span><span class="hs-comment">--    a 'System.IO.hFlush' is issued, or the handle is closed.</span><span>
</span><span id="line-217"></span><span class="hs-comment">--</span><span>
</span><span id="line-218"></span><span class="hs-comment">--  * /block-buffering/: the entire buffer is written out whenever it</span><span>
</span><span id="line-219"></span><span class="hs-comment">--    overflows, a 'System.IO.hFlush' is issued, or the handle is closed.</span><span>
</span><span id="line-220"></span><span class="hs-comment">--</span><span>
</span><span id="line-221"></span><span class="hs-comment">--  * /no-buffering/: output is written immediately, and never stored</span><span>
</span><span id="line-222"></span><span class="hs-comment">--    in the buffer.</span><span>
</span><span id="line-223"></span><span class="hs-comment">--</span><span>
</span><span id="line-224"></span><span class="hs-comment">-- An implementation is free to flush the buffer more frequently,</span><span>
</span><span id="line-225"></span><span class="hs-comment">-- but not less frequently, than specified above.</span><span>
</span><span id="line-226"></span><span class="hs-comment">-- The output buffer is emptied as soon as it has been written out.</span><span>
</span><span id="line-227"></span><span class="hs-comment">--</span><span>
</span><span id="line-228"></span><span class="hs-comment">-- Similarly, input occurs according to the buffer mode for the handle:</span><span>
</span><span id="line-229"></span><span class="hs-comment">--</span><span>
</span><span id="line-230"></span><span class="hs-comment">--  * /line-buffering/: when the buffer for the handle is not empty,</span><span>
</span><span id="line-231"></span><span class="hs-comment">--    the next item is obtained from the buffer; otherwise, when the</span><span>
</span><span id="line-232"></span><span class="hs-comment">--    buffer is empty, characters up to and including the next newline</span><span>
</span><span id="line-233"></span><span class="hs-comment">--    character are read into the buffer.  No characters are available</span><span>
</span><span id="line-234"></span><span class="hs-comment">--    until the newline character is available or the buffer is full.</span><span>
</span><span id="line-235"></span><span class="hs-comment">--</span><span>
</span><span id="line-236"></span><span class="hs-comment">--  * /block-buffering/: when the buffer for the handle becomes empty,</span><span>
</span><span id="line-237"></span><span class="hs-comment">--    the next block of data is read into the buffer.</span><span>
</span><span id="line-238"></span><span class="hs-comment">--</span><span>
</span><span id="line-239"></span><span class="hs-comment">--  * /no-buffering/: the next input item is read and returned.</span><span>
</span><span id="line-240"></span><span class="hs-comment">--    The 'System.IO.hLookAhead' operation implies that even a no-buffered</span><span>
</span><span id="line-241"></span><span class="hs-comment">--    handle may require a one-character buffer.</span><span>
</span><span id="line-242"></span><span class="hs-comment">--</span><span>
</span><span id="line-243"></span><span class="hs-comment">-- The default buffering mode when a handle is opened is</span><span>
</span><span id="line-244"></span><span class="hs-comment">-- implementation-dependent and may depend on the file system object</span><span>
</span><span id="line-245"></span><span class="hs-comment">-- which is attached to that handle.</span><span>
</span><span id="line-246"></span><span class="hs-comment">-- For most implementations, physical files will normally be block-buffered</span><span>
</span><span id="line-247"></span><span class="hs-comment">-- and terminals will normally be line-buffered.</span><span>
</span><span id="line-248"></span><span>
</span><span id="line-249"></span><span class="hs-keyword">data</span><span> </span><span id="BufferMode"><span class="annot"><a href="GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier hs-var">BufferMode</span></a></span></span><span>
</span><span id="line-250"></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="NoBuffering"><span class="annot"><a href="GHC.IO.Handle.Types.html#NoBuffering"><span class="hs-identifier hs-var">NoBuffering</span></a></span></span><span>  </span><span class="hs-comment">-- ^ buffering is disabled if possible.</span><span>
</span><span id="line-251"></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="LineBuffering"><span class="annot"><a href="GHC.IO.Handle.Types.html#LineBuffering"><span class="hs-identifier hs-var">LineBuffering</span></a></span></span><span>
</span><span id="line-252"></span><span>                </span><span class="hs-comment">-- ^ line-buffering should be enabled if possible.</span><span>
</span><span id="line-253"></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="BlockBuffering"><span class="annot"><a href="GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-var">BlockBuffering</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-254"></span><span>                </span><span class="hs-comment">-- ^ block-buffering should be enabled if possible.</span><span>
</span><span id="line-255"></span><span>                </span><span class="hs-comment">-- The size of the buffer is @n@ items if the argument</span><span>
</span><span id="line-256"></span><span>                </span><span class="hs-comment">-- is 'Just' @n@ and is otherwise implementation-dependent.</span><span>
</span><span id="line-257"></span><span>   </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span> </span><span id="local-6989586621679533874"><span id="local-6989586621679533879"><span class="annot"><span class="annottext">BufferMode -&gt; BufferMode -&gt; Bool
(BufferMode -&gt; BufferMode -&gt; Bool)
-&gt; (BufferMode -&gt; BufferMode -&gt; Bool) -&gt; Eq BufferMode
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: BufferMode -&gt; BufferMode -&gt; Bool
$c/= :: BufferMode -&gt; BufferMode -&gt; Bool
== :: BufferMode -&gt; BufferMode -&gt; Bool
$c== :: BufferMode -&gt; BufferMode -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span>   </span><span class="hs-comment">-- ^ @since 4.2.0.0</span><span>
</span><span id="line-258"></span><span>            </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533849"><span id="local-6989586621679533851"><span id="local-6989586621679533854"><span id="local-6989586621679533857"><span id="local-6989586621679533860"><span id="local-6989586621679533864"><span id="local-6989586621679533869"><span class="annot"><span class="annottext">Eq BufferMode
Eq BufferMode
-&gt; (BufferMode -&gt; BufferMode -&gt; Ordering)
-&gt; (BufferMode -&gt; BufferMode -&gt; Bool)
-&gt; (BufferMode -&gt; BufferMode -&gt; Bool)
-&gt; (BufferMode -&gt; BufferMode -&gt; Bool)
-&gt; (BufferMode -&gt; BufferMode -&gt; Bool)
-&gt; (BufferMode -&gt; BufferMode -&gt; BufferMode)
-&gt; (BufferMode -&gt; BufferMode -&gt; BufferMode)
-&gt; Ord BufferMode
BufferMode -&gt; BufferMode -&gt; Bool
BufferMode -&gt; BufferMode -&gt; Ordering
BufferMode -&gt; BufferMode -&gt; BufferMode
forall a.
Eq a
-&gt; (a -&gt; a -&gt; Ordering)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; Ord a
min :: BufferMode -&gt; BufferMode -&gt; BufferMode
$cmin :: BufferMode -&gt; BufferMode -&gt; BufferMode
max :: BufferMode -&gt; BufferMode -&gt; BufferMode
$cmax :: BufferMode -&gt; BufferMode -&gt; BufferMode
&gt;= :: BufferMode -&gt; BufferMode -&gt; Bool
$c&gt;= :: BufferMode -&gt; BufferMode -&gt; Bool
&gt; :: BufferMode -&gt; BufferMode -&gt; Bool
$c&gt; :: BufferMode -&gt; BufferMode -&gt; Bool
&lt;= :: BufferMode -&gt; BufferMode -&gt; Bool
$c&lt;= :: BufferMode -&gt; BufferMode -&gt; Bool
&lt; :: BufferMode -&gt; BufferMode -&gt; Bool
$c&lt; :: BufferMode -&gt; BufferMode -&gt; Bool
compare :: BufferMode -&gt; BufferMode -&gt; Ordering
$ccompare :: BufferMode -&gt; BufferMode -&gt; Ordering
</span><a href="../../ghc-prim/src/GHC.Classes.html#Ord"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Ord</span></a></span></span></span></span></span></span></span></span><span>  </span><span class="hs-comment">-- ^ @since 4.2.0.0</span><span>
</span><span id="line-259"></span><span>            </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533829"><span id="local-6989586621679533840"><span id="local-6989586621679533843"><span id="local-6989586621679533845"><span class="annot"><span class="annottext">ReadPrec [BufferMode]
ReadPrec BufferMode
Int -&gt; ReadS BufferMode
ReadS [BufferMode]
(Int -&gt; ReadS BufferMode)
-&gt; ReadS [BufferMode]
-&gt; ReadPrec BufferMode
-&gt; ReadPrec [BufferMode]
-&gt; Read BufferMode
forall a.
(Int -&gt; ReadS a)
-&gt; ReadS [a] -&gt; ReadPrec a -&gt; ReadPrec [a] -&gt; Read a
readListPrec :: ReadPrec [BufferMode]
$creadListPrec :: ReadPrec [BufferMode]
readPrec :: ReadPrec BufferMode
$creadPrec :: ReadPrec BufferMode
readList :: ReadS [BufferMode]
$creadList :: ReadS [BufferMode]
readsPrec :: Int -&gt; ReadS BufferMode
$creadsPrec :: Int -&gt; ReadS BufferMode
</span><a href="GHC.Read.html#Read"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Read</span></a></span></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.2.0.0</span><span>
</span><span id="line-260"></span><span>            </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533816"><span id="local-6989586621679533818"><span id="local-6989586621679533824"><span class="annot"><span class="annottext">Int -&gt; BufferMode -&gt; ShowS
[BufferMode] -&gt; ShowS
BufferMode -&gt; FilePath
(Int -&gt; BufferMode -&gt; ShowS)
-&gt; (BufferMode -&gt; FilePath)
-&gt; ([BufferMode] -&gt; ShowS)
-&gt; Show BufferMode
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; FilePath) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [BufferMode] -&gt; ShowS
$cshowList :: [BufferMode] -&gt; ShowS
show :: BufferMode -&gt; FilePath
$cshow :: BufferMode -&gt; FilePath
showsPrec :: Int -&gt; BufferMode -&gt; ShowS
$cshowsPrec :: Int -&gt; BufferMode -&gt; ShowS
</span><a href="GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.2.0.0</span><span>
</span><span id="line-261"></span><span>            </span><span class="hs-special">)</span><span>
</span><span id="line-262"></span><span>
</span><span id="line-263"></span><span class="hs-comment">{-
[note Buffering Implementation]

Each Handle has two buffers: a byte buffer (haByteBuffer) and a Char
buffer (haCharBuffer).

[note Buffered Reading]

For read Handles, bytes are read into the byte buffer, and immediately
decoded into the Char buffer (see
GHC.IO.Handle.Internals.readTextDevice).  The only way there might be
some data left in the byte buffer is if there is a partial multi-byte
character sequence that cannot be decoded into a full character.

Note that the buffering mode (haBufferMode) makes no difference when
reading data into a Handle.  When reading, we can always just read all
the data there is available without blocking, decode it into the Char
buffer, and then provide it immediately to the caller.

[note Buffered Writing]

Characters are written into the Char buffer by e.g. hPutStr.  At the
end of the operation, or when the char buffer is full, the buffer is
decoded to the byte buffer (see writeCharBuffer).  This is so that we
can detect encoding errors at the right point.

Hence, the Char buffer is always empty between Handle operations.

[note Buffer Sizing]

The char buffer is always a default size (dEFAULT_CHAR_BUFFER_SIZE).
The byte buffer size is chosen by the underlying device (via its
IODevice.newBuffer).  Hence the size of these buffers is not under
user control.

There are certain minimum sizes for these buffers imposed by the
library (but not checked):

 - we must be able to buffer at least one character, so that
   hLookAhead can work

 - the byte buffer must be able to store at least one encoded
   character in the current encoding (6 bytes?)

 - when reading, the char buffer must have room for two characters, so
   that we can spot the \r\n sequence.

How do we implement hSetBuffering?

For reading, we have never used the user-supplied buffer size, because
there's no point: we always pass all available data to the reader
immediately.  Buffering would imply waiting until a certain amount of
data is available, which has no advantages.  So hSetBuffering is
essentially a no-op for read handles, except that it turns on/off raw
mode for the underlying device if necessary.

For writing, the buffering mode is handled by the write operations
themselves (hPutChar and hPutStr).  Every write ends with
writeCharBuffer, which checks whether the buffer should be flushed
according to the current buffering mode.  Additionally, we look for
newlines and flush if the mode is LineBuffering.

[note Buffer Flushing]

** Flushing the Char buffer

We must be able to flush the Char buffer, in order to implement
hSetEncoding, and things like hGetBuf which want to read raw bytes.

Flushing the Char buffer on a write Handle is easy: it is always empty.

Flushing the Char buffer on a read Handle involves rewinding the byte
buffer to the point representing the next Char in the Char buffer.
This is done by

 - remembering the state of the byte buffer *before* the last decode

 - re-decoding the bytes that represent the chars already read from the
   Char buffer.  This gives us the point in the byte buffer that
   represents the *next* Char to be read.

In order for this to work, after readTextHandle we must NOT MODIFY THE
CONTENTS OF THE BYTE OR CHAR BUFFERS, except to remove characters from
the Char buffer.

** Flushing the byte buffer

The byte buffer can be flushed if the Char buffer has already been
flushed (see above).  For a read Handle, flushing the byte buffer
means seeking the device back by the number of bytes in the buffer,
and hence it is only possible on a seekable Handle.

-}</span><span>
</span><span id="line-356"></span><span>
</span><span id="line-357"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-358"></span><span class="hs-comment">-- Newline translation</span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span class="hs-comment">-- | The representation of a newline in the external file or stream.</span><span>
</span><span id="line-361"></span><span class="hs-keyword">data</span><span> </span><span id="Newline"><span class="annot"><a href="GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier hs-var">Newline</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="LF"><span class="annot"><a href="GHC.IO.Handle.Types.html#LF"><span class="hs-identifier hs-var">LF</span></a></span></span><span>    </span><span class="hs-comment">-- ^ @\'\\n\'@</span><span>
</span><span id="line-362"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span id="CRLF"><span class="annot"><a href="GHC.IO.Handle.Types.html#CRLF"><span class="hs-identifier hs-var">CRLF</span></a></span></span><span>  </span><span class="hs-comment">-- ^ @\'\\r\\n\'@</span><span>
</span><span id="line-363"></span><span>             </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span> </span><span id="local-6989586621679533808"><span id="local-6989586621679533810"><span class="annot"><span class="annottext">Newline -&gt; Newline -&gt; Bool
(Newline -&gt; Newline -&gt; Bool)
-&gt; (Newline -&gt; Newline -&gt; Bool) -&gt; Eq Newline
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: Newline -&gt; Newline -&gt; Bool
$c/= :: Newline -&gt; Newline -&gt; Bool
== :: Newline -&gt; Newline -&gt; Bool
$c== :: Newline -&gt; Newline -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span>   </span><span class="hs-comment">-- ^ @since 4.2.0.0</span><span>
</span><span id="line-364"></span><span>                      </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533789"><span id="local-6989586621679533791"><span id="local-6989586621679533794"><span id="local-6989586621679533797"><span id="local-6989586621679533800"><span id="local-6989586621679533802"><span id="local-6989586621679533804"><span class="annot"><span class="annottext">Eq Newline
Eq Newline
-&gt; (Newline -&gt; Newline -&gt; Ordering)
-&gt; (Newline -&gt; Newline -&gt; Bool)
-&gt; (Newline -&gt; Newline -&gt; Bool)
-&gt; (Newline -&gt; Newline -&gt; Bool)
-&gt; (Newline -&gt; Newline -&gt; Bool)
-&gt; (Newline -&gt; Newline -&gt; Newline)
-&gt; (Newline -&gt; Newline -&gt; Newline)
-&gt; Ord Newline
Newline -&gt; Newline -&gt; Bool
Newline -&gt; Newline -&gt; Ordering
Newline -&gt; Newline -&gt; Newline
forall a.
Eq a
-&gt; (a -&gt; a -&gt; Ordering)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; Ord a
min :: Newline -&gt; Newline -&gt; Newline
$cmin :: Newline -&gt; Newline -&gt; Newline
max :: Newline -&gt; Newline -&gt; Newline
$cmax :: Newline -&gt; Newline -&gt; Newline
&gt;= :: Newline -&gt; Newline -&gt; Bool
$c&gt;= :: Newline -&gt; Newline -&gt; Bool
&gt; :: Newline -&gt; Newline -&gt; Bool
$c&gt; :: Newline -&gt; Newline -&gt; Bool
&lt;= :: Newline -&gt; Newline -&gt; Bool
$c&lt;= :: Newline -&gt; Newline -&gt; Bool
&lt; :: Newline -&gt; Newline -&gt; Bool
$c&lt; :: Newline -&gt; Newline -&gt; Bool
compare :: Newline -&gt; Newline -&gt; Ordering
$ccompare :: Newline -&gt; Newline -&gt; Ordering
</span><a href="../../ghc-prim/src/GHC.Classes.html#Ord"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Ord</span></a></span></span></span></span></span></span></span></span><span>  </span><span class="hs-comment">-- ^ @since 4.3.0.0</span><span>
</span><span id="line-365"></span><span>                      </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533778"><span id="local-6989586621679533782"><span id="local-6989586621679533785"><span id="local-6989586621679533787"><span class="annot"><span class="annottext">ReadPrec [Newline]
ReadPrec Newline
Int -&gt; ReadS Newline
ReadS [Newline]
(Int -&gt; ReadS Newline)
-&gt; ReadS [Newline]
-&gt; ReadPrec Newline
-&gt; ReadPrec [Newline]
-&gt; Read Newline
forall a.
(Int -&gt; ReadS a)
-&gt; ReadS [a] -&gt; ReadPrec a -&gt; ReadPrec [a] -&gt; Read a
readListPrec :: ReadPrec [Newline]
$creadListPrec :: ReadPrec [Newline]
readPrec :: ReadPrec Newline
$creadPrec :: ReadPrec Newline
readList :: ReadS [Newline]
$creadList :: ReadS [Newline]
readsPrec :: Int -&gt; ReadS Newline
$creadsPrec :: Int -&gt; ReadS Newline
</span><a href="GHC.Read.html#Read"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Read</span></a></span></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.3.0.0</span><span>
</span><span id="line-366"></span><span>                      </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533771"><span id="local-6989586621679533773"><span id="local-6989586621679533775"><span class="annot"><span class="annottext">Int -&gt; Newline -&gt; ShowS
[Newline] -&gt; ShowS
Newline -&gt; FilePath
(Int -&gt; Newline -&gt; ShowS)
-&gt; (Newline -&gt; FilePath) -&gt; ([Newline] -&gt; ShowS) -&gt; Show Newline
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; FilePath) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [Newline] -&gt; ShowS
$cshowList :: [Newline] -&gt; ShowS
show :: Newline -&gt; FilePath
$cshow :: Newline -&gt; FilePath
showsPrec :: Int -&gt; Newline -&gt; ShowS
$cshowsPrec :: Int -&gt; Newline -&gt; ShowS
</span><a href="GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.3.0.0</span><span>
</span><span id="line-367"></span><span>                      </span><span class="hs-special">)</span><span>
</span><span id="line-368"></span><span>
</span><span id="line-369"></span><span class="hs-comment">-- | Specifies the translation, if any, of newline characters between</span><span>
</span><span id="line-370"></span><span class="hs-comment">-- internal Strings and the external file or stream.  Haskell Strings</span><span>
</span><span id="line-371"></span><span class="hs-comment">-- are assumed to represent newlines with the @\'\\n\'@ character; the</span><span>
</span><span id="line-372"></span><span class="hs-comment">-- newline mode specifies how to translate @\'\\n\'@ on output, and what to</span><span>
</span><span id="line-373"></span><span class="hs-comment">-- translate into @\'\\n\'@ on input.</span><span>
</span><span id="line-374"></span><span class="hs-keyword">data</span><span> </span><span id="NewlineMode"><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-var">NewlineMode</span></a></span></span><span>
</span><span id="line-375"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="NewlineMode"><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-var">NewlineMode</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="inputNL"><span class="annot"><span class="annottext">NewlineMode -&gt; Newline
</span><a href="GHC.IO.Handle.Types.html#inputNL"><span class="hs-identifier hs-var hs-var">inputNL</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier hs-type">Newline</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-376"></span><span>                    </span><span class="hs-comment">-- ^ the representation of newlines on input</span><span>
</span><span id="line-377"></span><span>                  </span><span id="outputNL"><span class="annot"><span class="annottext">NewlineMode -&gt; Newline
</span><a href="GHC.IO.Handle.Types.html#outputNL"><span class="hs-identifier hs-var hs-var">outputNL</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier hs-type">Newline</span></a></span><span>
</span><span id="line-378"></span><span>                    </span><span class="hs-comment">-- ^ the representation of newlines on output</span><span>
</span><span id="line-379"></span><span>                 </span><span class="hs-special">}</span><span>
</span><span id="line-380"></span><span>             </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span> </span><span id="local-6989586621679533762"><span id="local-6989586621679533766"><span class="annot"><span class="annottext">NewlineMode -&gt; NewlineMode -&gt; Bool
(NewlineMode -&gt; NewlineMode -&gt; Bool)
-&gt; (NewlineMode -&gt; NewlineMode -&gt; Bool) -&gt; Eq NewlineMode
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: NewlineMode -&gt; NewlineMode -&gt; Bool
$c/= :: NewlineMode -&gt; NewlineMode -&gt; Bool
== :: NewlineMode -&gt; NewlineMode -&gt; Bool
$c== :: NewlineMode -&gt; NewlineMode -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span>   </span><span class="hs-comment">-- ^ @since 4.2.0.0</span><span>
</span><span id="line-381"></span><span>                      </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533739"><span id="local-6989586621679533741"><span id="local-6989586621679533744"><span id="local-6989586621679533747"><span id="local-6989586621679533750"><span id="local-6989586621679533754"><span id="local-6989586621679533758"><span class="annot"><span class="annottext">Eq NewlineMode
Eq NewlineMode
-&gt; (NewlineMode -&gt; NewlineMode -&gt; Ordering)
-&gt; (NewlineMode -&gt; NewlineMode -&gt; Bool)
-&gt; (NewlineMode -&gt; NewlineMode -&gt; Bool)
-&gt; (NewlineMode -&gt; NewlineMode -&gt; Bool)
-&gt; (NewlineMode -&gt; NewlineMode -&gt; Bool)
-&gt; (NewlineMode -&gt; NewlineMode -&gt; NewlineMode)
-&gt; (NewlineMode -&gt; NewlineMode -&gt; NewlineMode)
-&gt; Ord NewlineMode
NewlineMode -&gt; NewlineMode -&gt; Bool
NewlineMode -&gt; NewlineMode -&gt; Ordering
NewlineMode -&gt; NewlineMode -&gt; NewlineMode
forall a.
Eq a
-&gt; (a -&gt; a -&gt; Ordering)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; Ord a
min :: NewlineMode -&gt; NewlineMode -&gt; NewlineMode
$cmin :: NewlineMode -&gt; NewlineMode -&gt; NewlineMode
max :: NewlineMode -&gt; NewlineMode -&gt; NewlineMode
$cmax :: NewlineMode -&gt; NewlineMode -&gt; NewlineMode
&gt;= :: NewlineMode -&gt; NewlineMode -&gt; Bool
$c&gt;= :: NewlineMode -&gt; NewlineMode -&gt; Bool
&gt; :: NewlineMode -&gt; NewlineMode -&gt; Bool
$c&gt; :: NewlineMode -&gt; NewlineMode -&gt; Bool
&lt;= :: NewlineMode -&gt; NewlineMode -&gt; Bool
$c&lt;= :: NewlineMode -&gt; NewlineMode -&gt; Bool
&lt; :: NewlineMode -&gt; NewlineMode -&gt; Bool
$c&lt; :: NewlineMode -&gt; NewlineMode -&gt; Bool
compare :: NewlineMode -&gt; NewlineMode -&gt; Ordering
$ccompare :: NewlineMode -&gt; NewlineMode -&gt; Ordering
</span><a href="../../ghc-prim/src/GHC.Classes.html#Ord"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Ord</span></a></span></span></span></span></span></span></span></span><span>  </span><span class="hs-comment">-- ^ @since 4.3.0.0</span><span>
</span><span id="line-382"></span><span>                      </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533721"><span id="local-6989586621679533732"><span id="local-6989586621679533735"><span id="local-6989586621679533737"><span class="annot"><span class="annottext">ReadPrec [NewlineMode]
ReadPrec NewlineMode
Int -&gt; ReadS NewlineMode
ReadS [NewlineMode]
(Int -&gt; ReadS NewlineMode)
-&gt; ReadS [NewlineMode]
-&gt; ReadPrec NewlineMode
-&gt; ReadPrec [NewlineMode]
-&gt; Read NewlineMode
forall a.
(Int -&gt; ReadS a)
-&gt; ReadS [a] -&gt; ReadPrec a -&gt; ReadPrec [a] -&gt; Read a
readListPrec :: ReadPrec [NewlineMode]
$creadListPrec :: ReadPrec [NewlineMode]
readPrec :: ReadPrec NewlineMode
$creadPrec :: ReadPrec NewlineMode
readList :: ReadS [NewlineMode]
$creadList :: ReadS [NewlineMode]
readsPrec :: Int -&gt; ReadS NewlineMode
$creadsPrec :: Int -&gt; ReadS NewlineMode
</span><a href="GHC.Read.html#Read"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Read</span></a></span></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.3.0.0</span><span>
</span><span id="line-383"></span><span>                      </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679533711"><span id="local-6989586621679533713"><span id="local-6989586621679533718"><span class="annot"><span class="annottext">Int -&gt; NewlineMode -&gt; ShowS
[NewlineMode] -&gt; ShowS
NewlineMode -&gt; FilePath
(Int -&gt; NewlineMode -&gt; ShowS)
-&gt; (NewlineMode -&gt; FilePath)
-&gt; ([NewlineMode] -&gt; ShowS)
-&gt; Show NewlineMode
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; FilePath) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [NewlineMode] -&gt; ShowS
$cshowList :: [NewlineMode] -&gt; ShowS
show :: NewlineMode -&gt; FilePath
$cshow :: NewlineMode -&gt; FilePath
showsPrec :: Int -&gt; NewlineMode -&gt; ShowS
$cshowsPrec :: Int -&gt; NewlineMode -&gt; ShowS
</span><a href="GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.3.0.0</span><span>
</span><span id="line-384"></span><span>                      </span><span class="hs-special">)</span><span>
</span><span id="line-385"></span><span>
</span><span id="line-386"></span><span class="hs-comment">-- | The native newline representation for the current platform: 'LF'</span><span>
</span><span id="line-387"></span><span class="hs-comment">-- on Unix systems, 'CRLF' on Windows.</span><span>
</span><span id="line-388"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#nativeNewline"><span class="hs-identifier hs-type">nativeNewline</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier hs-type">Newline</span></a></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span id="nativeNewline"><span class="annot"><span class="annottext">nativeNewline :: Newline
</span><a href="GHC.IO.Handle.Types.html#nativeNewline"><span class="hs-identifier hs-var hs-var">nativeNewline</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="GHC.IO.Handle.Types.html#CRLF"><span class="hs-identifier hs-var">CRLF</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-identifier">nativeNewline</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">LF</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-395"></span><span class="hs-comment">-- | Map @\'\\r\\n\'@ into @\'\\n\'@ on input, and @\'\\n\'@ to the native newline</span><span>
</span><span id="line-396"></span><span class="hs-comment">-- representation on output.  This mode can be used on any platform, and</span><span>
</span><span id="line-397"></span><span class="hs-comment">-- works with text files using any newline convention.  The downside is</span><span>
</span><span id="line-398"></span><span class="hs-comment">-- that @readFile &gt;&gt;= writeFile@ might yield a different file.</span><span>
</span><span id="line-399"></span><span class="hs-comment">--</span><span>
</span><span id="line-400"></span><span class="hs-comment">-- &gt; universalNewlineMode  = NewlineMode { inputNL  = CRLF,</span><span>
</span><span id="line-401"></span><span class="hs-comment">-- &gt;                                       outputNL = nativeNewline }</span><span>
</span><span id="line-402"></span><span class="hs-comment">--</span><span>
</span><span id="line-403"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#universalNewlineMode"><span class="hs-identifier hs-type">universalNewlineMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span>
</span><span id="line-404"></span><span id="universalNewlineMode"><span class="annot"><span class="annottext">universalNewlineMode :: NewlineMode
</span><a href="GHC.IO.Handle.Types.html#universalNewlineMode"><span class="hs-identifier hs-var hs-var">universalNewlineMode</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NewlineMode :: Newline -&gt; Newline -&gt; NewlineMode
</span><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">inputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#inputNL"><span class="hs-identifier hs-var">inputNL</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="GHC.IO.Handle.Types.html#CRLF"><span class="hs-identifier hs-var">CRLF</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-405"></span><span>                                      </span><span class="annot"><span class="annottext">outputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#outputNL"><span class="hs-identifier hs-var">outputNL</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="GHC.IO.Handle.Types.html#nativeNewline"><span class="hs-identifier hs-var">nativeNewline</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-406"></span><span>
</span><span id="line-407"></span><span class="hs-comment">-- | Use the native newline representation on both input and output</span><span>
</span><span id="line-408"></span><span class="hs-comment">--</span><span>
</span><span id="line-409"></span><span class="hs-comment">-- &gt; nativeNewlineMode  = NewlineMode { inputNL  = nativeNewline</span><span>
</span><span id="line-410"></span><span class="hs-comment">-- &gt;                                    outputNL = nativeNewline }</span><span>
</span><span id="line-411"></span><span class="hs-comment">--</span><span>
</span><span id="line-412"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#nativeNewlineMode"><span class="hs-identifier hs-type">nativeNewlineMode</span></a></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span>
</span><span id="line-413"></span><span id="nativeNewlineMode"><span class="annot"><span class="annottext">nativeNewlineMode :: NewlineMode
</span><a href="GHC.IO.Handle.Types.html#nativeNewlineMode"><span class="hs-identifier hs-var hs-var">nativeNewlineMode</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NewlineMode :: Newline -&gt; Newline -&gt; NewlineMode
</span><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">inputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#inputNL"><span class="hs-identifier hs-var">inputNL</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="GHC.IO.Handle.Types.html#nativeNewline"><span class="hs-identifier hs-var">nativeNewline</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-414"></span><span>                                      </span><span class="annot"><span class="annottext">outputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#outputNL"><span class="hs-identifier hs-var">outputNL</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="GHC.IO.Handle.Types.html#nativeNewline"><span class="hs-identifier hs-var">nativeNewline</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-415"></span><span>
</span><span id="line-416"></span><span class="hs-comment">-- | Do no newline translation at all.</span><span>
</span><span id="line-417"></span><span class="hs-comment">--</span><span>
</span><span id="line-418"></span><span class="hs-comment">-- &gt; noNewlineTranslation  = NewlineMode { inputNL  = LF, outputNL = LF }</span><span>
</span><span id="line-419"></span><span class="hs-comment">--</span><span>
</span><span id="line-420"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#noNewlineTranslation"><span class="hs-identifier hs-type">noNewlineTranslation</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span>
</span><span id="line-421"></span><span id="noNewlineTranslation"><span class="annot"><span class="annottext">noNewlineTranslation :: NewlineMode
</span><a href="GHC.IO.Handle.Types.html#noNewlineTranslation"><span class="hs-identifier hs-var hs-var">noNewlineTranslation</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NewlineMode :: Newline -&gt; Newline -&gt; NewlineMode
</span><a href="GHC.IO.Handle.Types.html#NewlineMode"><span class="hs-identifier hs-type">NewlineMode</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">inputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#inputNL"><span class="hs-identifier hs-var">inputNL</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="GHC.IO.Handle.Types.html#LF"><span class="hs-identifier hs-var">LF</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">outputNL :: Newline
</span><a href="GHC.IO.Handle.Types.html#outputNL"><span class="hs-identifier hs-var">outputNL</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="GHC.IO.Handle.Types.html#LF"><span class="hs-identifier hs-var">LF</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-422"></span><span>
</span><span id="line-423"></span><span class="hs-comment">-- ---------------------------------------------------------------------------</span><span>
</span><span id="line-424"></span><span class="hs-comment">-- Show instance for Handles</span><span>
</span><span id="line-425"></span><span>
</span><span id="line-426"></span><span class="hs-comment">-- handle types are 'show'n when printing error msgs, so</span><span>
</span><span id="line-427"></span><span class="hs-comment">-- we provide a more user-friendly Show instance for it</span><span>
</span><span id="line-428"></span><span class="hs-comment">-- than the derived one.</span><span>
</span><span id="line-429"></span><span>
</span><span id="line-430"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-431"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679533706"><span id="local-6989586621679533708"><span class="annot"><a href="GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier hs-type">HandleType</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-432"></span><span>  </span><span id="local-6989586621679533705"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; HandleType -&gt; ShowS
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679533703"><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679533703"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-433"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HandleType
</span><a href="#local-6989586621679533703"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-434"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;closed&quot;</span></span><span>
</span><span id="line-435"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;semi-closed&quot;</span></span><span>
</span><span id="line-436"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ReadHandle"><span class="hs-identifier hs-var">ReadHandle</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;readable&quot;</span></span><span>
</span><span id="line-437"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#WriteHandle"><span class="hs-identifier hs-var">WriteHandle</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;writable&quot;</span></span><span>
</span><span id="line-438"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#AppendHandle"><span class="hs-identifier hs-var">AppendHandle</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;writable (append)&quot;</span></span><span>
</span><span id="line-439"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="GHC.IO.Handle.Types.html#ReadWriteHandle"><span class="hs-identifier hs-var">ReadWriteHandle</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;read-writable&quot;</span></span><span>
</span><span id="line-440"></span><span>
</span><span id="line-441"></span><span class="hs-comment">-- | @since 4.1.0.0</span><span>
</span><span id="line-442"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679533697"><span id="local-6989586621679533699"><span class="annot"><a href="GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-443"></span><span>  </span><span id="local-6989586621679533696"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; Handle -&gt; ShowS
</span><a href="#local-6989586621679533696"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#FileHandle"><span class="hs-identifier hs-type">FileHandle</span></a></span><span>   </span><span id="local-6989586621679533695"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679533695"><span class="hs-identifier hs-var">file</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.IO.Handle.Types.html#showHandle"><span class="hs-identifier hs-var">showHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679533695"><span class="hs-identifier hs-var">file</span></a></span><span>
</span><span id="line-444"></span><span>  </span><span class="annot"><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var">showsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Handle.Types.html#DuplexHandle"><span class="hs-identifier hs-type">DuplexHandle</span></a></span><span> </span><span id="local-6989586621679533694"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679533694"><span class="hs-identifier hs-var">file</span></a></span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">MVar Handle__
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.IO.Handle.Types.html#showHandle"><span class="hs-identifier hs-var">showHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679533694"><span class="hs-identifier hs-var">file</span></a></span><span>
</span><span id="line-445"></span><span>
</span><span id="line-446"></span><span class="annot"><a href="GHC.IO.Handle.Types.html#showHandle"><span class="hs-identifier hs-type">showHandle</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-447"></span><span id="showHandle"><span class="annot"><span class="annottext">showHandle :: FilePath -&gt; ShowS
</span><a href="GHC.IO.Handle.Types.html#showHandle"><span class="hs-identifier hs-var hs-var">showHandle</span></a></span></span><span> </span><span id="local-6989586621679533693"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679533693"><span class="hs-identifier hs-var">file</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;{handle: &quot;</span></span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679533693"><span class="hs-identifier hs-var">file</span></a></span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;}&quot;</span></span><span>
</span><span id="line-448"></span><span>
</span><span id="line-449"></span></pre></body></html>